package champPackage;

import java.util.Iterator;

public class User {
	
	/**
	 * information about user is passed to the constructor
	 * @param userName
	 * @param password
	 * @param email
	 */
	public User(String userName, String password, String email, String type){
		this.userName = userName;
		this.password = password;
		this.email = email;
		userType = type;
	}
	
	/**
	 * user adds new championships
	 * @param ch
	 */
	public void addChampionship(Championship ch){
		int champ_id = ch.getId();
		
	}
	/**
	 * return all the championship object which was organized by this user
	 * @return
	 */
	public Iterator<Championship> getUserChampionships(){
		return null;
	}
	
	/**
	 * reutrns emails of the user
	 * @return
	 */
	public String getEmail(){
		return email;
	}
	
	/**
	 * Checks whether the user info is valid. It means that userName is not null and contains at least 4 symbols, as well as password.
	 * It also checks whether the email contains the symbol '@'. If some of these conditions fail, we assume that the user info is invalid. 
	 */
	static boolean isValidInfo(String userName, String password, String email){
		if(userName==null || password==null || email==null) return false;
		System.out.println("nullebis problema ar aris");
		boolean found = false;
		for(int i=0; i<email.length(); i++){
			if(email.charAt(i)=='@'){
				found = true;
				continue;
			}
		}
		return found && userName.length()>=4 && password.length()>=4;
	}
	
	/**
	 * organizatoris ID
	 * @return
	 */
	// aq id-s vgulisxmobt rom tviton userName aris da int-s es metodi ver daabrunebs.
	public int getID(){
		return 0;
	}
	
	public String getUserType(){
		return userType;
	}
	
	private String userName, password, email, userType;

}
